New memory_op subops which return the apparent or actual physical address map.
authorIan.Campbell@xensource.com <Ian.Campbell@xensource.com>
Mon, 22 May 2006 08:22:18 +0000 (09:22 +0100)
committerIan.Campbell@xensource.com <Ian.Campbell@xensource.com>
Mon, 22 May 2006 08:22:18 +0000 (09:22 +0100)
The new subops return a memory map in e820 format. This will allow the
removal of some Xen special casing in the Linux port by using the same
code as native.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
xen/arch/x86/mm.c
xen/include/public/memory.h

index 7e78e680e771dc81867756475fa76a9ef1312723..e614f3dc74be72ef78fe61bd64a9647c3f4ce766 100644 (file)
@@ -2811,6 +2811,8 @@ long do_update_descriptor(u64 pa, u64 desc)
     return ret;
 }
 
+typedef struct e820entry e820entry_t;
+DEFINE_XEN_GUEST_HANDLE(e820entry_t);
 
 long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
@@ -2869,6 +2871,39 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
+    case XENMEM_memory_map:
+    {
+        return -ENOSYS;
+    }
+
+    case XENMEM_machine_memory_map:
+    {
+        struct xen_memory_map memmap;
+        XEN_GUEST_HANDLE(e820entry_t) buffer;
+        int count;
+
+        if ( !IS_PRIV(current->domain) )
+            return -EINVAL;
+
+        if ( copy_from_guest(&memmap, arg, 1) )
+            return -EFAULT;
+        if ( memmap.nr_entries < e820.nr_map + 1 )
+            return -EINVAL;
+
+        buffer = guest_handle_cast(memmap.buffer, e820entry_t);
+
+        count = min((unsigned int)e820.nr_map, memmap.nr_entries);
+        if ( copy_to_guest(buffer, &e820.map[0], count) < 0 )
+            return -EFAULT;
+
+        memmap.nr_entries = count;
+
+        if ( copy_to_guest(arg, &memmap, 1) )
+            return -EFAULT;
+
+        return 0;
+    }
+
     default:
         return subarch_memory_op(op, arg);
     }
index 75818c53b635fb6c64d6a8f852b3633b43a3ae83..bd2e265a5a955d2b1c0f363102ff03cfcc0fec01 100644 (file)
@@ -146,6 +146,34 @@ struct xen_translate_gpfn_list {
 typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
 DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
 
+/*
+ * Returns the pseudo-physical memory map as it was when the domain
+ * was started.
+ */
+#define XENMEM_memory_map           9
+struct xen_memory_map {
+    /*
+     * On call the number of entries which can be stored in buffer. On
+     * return the number of entries which have been stored in
+     * buffer.
+     */
+    unsigned int nr_entries;
+
+    /*
+     * Entries in the buffer are in the same format as returned by the
+     * BIOS INT 0x15 EAX=0xE820 call.
+     */
+    XEN_GUEST_HANDLE(void) buffer;
+};
+typedef struct xen_memory_map xen_memory_map_t;
+DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
+
+/*
+ * Returns the real physical memory map. Passes the same structure as
+ * XENMEM_memory_map.
+ */
+#define XENMEM_machine_memory_map      10
+
 #endif /* __XEN_PUBLIC_MEMORY_H__ */
 
 /*